
<template>
  <div class="app-container finance-container" v-loading="boo.loading">
    <left-board :base-data="baseData" :account-type="accountType" :phone="phone"/>
    <finance-list :base-data="baseData"/>
  </div>
</template>

<script>
import {
  getFinanceIndex, editPayPassword
} from "@/api/financeManage/shop-finance";
export default {
  name: "adminFinance",
  components: {
    "left-board": () => import("./storeFinance/left-board.vue"),
    "finance-list": () => import("./storeFinance/finance-list.vue"),
  },
  beforeRouteEnter (to, from, next){
    let routeList = [
      {name: '', status: [1, 5], desc: '未开户、开户成功'},
      {name: '', status: [2, 3, 4], desc: '审核中、审核失败、审核成功'},
      {name: '', status: [6], desc: '激活账户'},
    ]
    getFinanceIndex().then(res => {
      // next('/finance/active-account')
      // return
      let {shopMessageStatus = 1, shopMessage = {}} = res.data
      if(shopMessageStatus == 1 || shopMessageStatus == 5){ // 未开户
        next()
      } else if(shopMessageStatus == 6){
        next('/finance/active-account')
      }else{
        let {accountType} = shopMessage
        if(accountType == 1){
          next('/finance/action-card-person', 'add')
        }else{
          next('/finance/action-card-company', 'add')
        }        
      }
    })
  },
  data() {
    return { 
      boo: {
        loading: true
      },     
      accountType: -1, //开户类型
      phone: '', //绑定的手机号
      baseData: {
        shopMessageStatus: 1
      },
    };
  },
  mounted(){
    let _self = this
    _self.queryFinanceIndex()
  },
  methods: {
    queryFinanceIndex(){
      let _self = this
      _self.boo.loading = true
      getFinanceIndex().then(res => {
        let {accountType, accountPhone} = res.data['shopMessage']
        _self.accountType = accountType
        _self.baseData = res.data
        _self.phone = accountPhone
      }).finally(() => _self.boo.loading = false)
    },
    
  }
};
</script>
<style scoped lang="scss">
.finance-container {
  padding: vh(20) vw(30);
  min-height: calc(100vh - 54px);
  display: flex;
}
</style>